﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="login.aspx.cs" Inherits="login" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>LogIn - FB Integration</title>
    <link rel="shortcut icon" href="Resource/Img/favicon_favicon.png" />
    <script src="<%=ResolveClientUrl("~/Resource/js/jquery-1.11.1.min.js")%>" type="text/javascript"></script>
    <script src="<%=ResolveClientUrl("~/Resource/js/bootstrap.min.js")%>" type="text/javascript"></script>
    <link href="<%=ResolveClientUrl("~/Resource/css/bootstrap.min.css")%>" rel="stylesheet" type="text/css" />
    <script src="<%=ResolveClientUrl("~/Resource/js/jquery.validate.js")%>" type="text/javascript"></script>

    <script language="javascript" type="text/javascript">
        $(document).ready(function () {

            $('#btn-login').click(function () {
                var kode = $('#login-username').val();
                var pwd = $('#login-password').val();

                // alert(kode);

                var objUser = new Object();
                //                objUser.UserCode = encodeURIComponent(kode);
                //                objUser.IsPersistent = isPersistent;


                //                if (typeof ($('#txtPassword').val()) != 'undefined')
                //                    objUser.Password = encodeURIComponent($.sha1($('#txtPassword').val()));


                objUser.UserCode = encodeURIComponent(kode);
                objUser.Password = pwd;

                jsonData = JSON.stringify(objUser);

                $.ajax({
                    type: 'POST',
                    url: 'handler/loginhandler.ashx',
                    contentType: 'application/json',
                    dataType: 'json',
                    data: jsonData,
                    success: function (data) {
                        if (data.IsValid == 'True') {
                            window.location = data.DefaultUrl;

                        }
                        else {
                            alert(data.Message);
                            //$.msgBox(data.Message, null, { title: "Pesan Error" });
                        }

                    },
                    error: function (response) {
                        //var r = JSON.parse(response.responseText);
                        //alert("Error Message: " + r.Message);
                        //$.msgBox("Error Message: " + r.Message, null, { title: "Pesan Error" });
                        //alert(r.Message);
                        alert(response.responseText);
                    }
                });

                return false;
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div class="container">    
        <div id="loginbox" style="margin-top:50px;" class="mainbox col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2">                    
            <div class="panel panel-info" >
                    <div class="panel-heading">
                        <div class="panel-title">Sign In</div>
                        <div style="float:right; font-size: 80%; position: relative; top:-10px"><a href="#">Forgot password?</a></div>
                    </div>     

                    <div style="padding-top:30px" class="panel-body" >

                        <div style="display:none" id="login-alert" class="alert alert-danger col-sm-12"></div>
                            
                        <%--<form id="loginform" class="form-horizontal" role="form">--%>
                                    
                            <div style="margin-bottom: 25px" class="input-group">
                                        <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
                                        <input id="login-username" type="text" class="form-control" name="username" value="" placeholder="email">                                        
                                    </div>
                                
                            <div style="margin-bottom: 25px" class="input-group">
                                        <span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
                                        <input id="login-password" type="password" class="form-control" name="password" placeholder="password">
                                    </div>
                                    

                                
                            <div class="input-group">
                                      <div class="checkbox">
                                        <label>
                                         <%-- <input id="login-remember" type="checkbox" name="remember" value="1"> Remember me--%>
                                        </label>
                                      </div>
                                    </div>


                                <div style="margin-top:10px" class="form-group">
                                    <!-- Button -->

                                    <div class="col-sm-12 controls">
                                      <%--<a id="btn-login1" href="#" class="btn btn-success">Login  </a>--%>
                                      <%--<a id="btn-fblogin" href="#" class="btn btn-primary">Login with Facebook</a>--%>

                                      <input  id="btn-login" type="submit" value="Login" class="btn btn-success" />

                                    </div>
                                </div>


                                <%--<div class="form-group">
                                    <div class="col-md-12 control">
                                        <div style="border-top: 1px solid#888; padding-top:15px; font-size:85%" >
                                            Don't have an account! 
                                        <a href="#" onClick="$('#loginbox').hide(); $('#signupbox').show()">
                                            Sign Up Here
                                        </a>
                                        </div>
                                    </div>
                                </div> --%>   
                            <%--</form> --%>    



                        </div>                     
                    </div>  
        </div>
        <div id="signupbox" style="display:none; margin-top:50px" class="mainbox col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2">
                    <div class="panel panel-info">
                        <div class="panel-heading">
                            <div class="panel-title">Sign Up</div>
                            <div style="float:right; font-size: 85%; position: relative; top:-10px"><a id="signinlink" href="#" onclick="$('#signupbox').hide(); $('#loginbox').show()">Sign In</a></div>
                        </div>  
                        <div class="panel-body" >
                            <form id="signupform" class="form-horizontal" role="form">
                                
                                <div id="signupalert" style="display:none" class="alert alert-danger">
                                    <p>Error:</p>
                                    <span></span>
                                </div>
                                    
                                
                                  
                                <div class="form-group">
                                    <label for="email" class="col-md-3 control-label">Email</label>
                                    <div class="col-md-9">
                                        <input type="text" class="form-control" name="email" placeholder="Email Address">
                                    </div>
                                </div>
                                    
                                <div class="form-group">
                                    <label for="firstname" class="col-md-3 control-label">First Name</label>
                                    <div class="col-md-9">
                                        <input type="text" class="form-control" name="firstname" placeholder="First Name">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="lastname" class="col-md-3 control-label">Last Name</label>
                                    <div class="col-md-9">
                                        <input type="text" class="form-control" name="lastname" placeholder="Last Name">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="password" class="col-md-3 control-label">Password</label>
                                    <div class="col-md-9">
                                        <input type="password" class="form-control" name="passwd" placeholder="Password">
                                    </div>
                                </div>
                                    
                                <div class="form-group">
                                    <label for="icode" class="col-md-3 control-label">Invitation Code</label>
                                    <div class="col-md-9">
                                        <input type="text" class="form-control" name="icode" placeholder="">
                                    </div>
                                </div>

                                <div class="form-group">
                                    <!-- Button -->                                        
                                    <div class="col-md-offset-3 col-md-9">
                                        <button id="btn-signup" type="button" class="btn btn-info"><i class="icon-hand-right"></i> &nbsp Sign Up</button>
                                        <span style="margin-left:8px;">or</span>  
                                    </div>
                                </div>
                                
                                <div style="border-top: 1px solid #999; padding-top:20px"  class="form-group">
                                    
                                    <div class="col-md-offset-3 col-md-9">
                                        <button id="btn-fbsignup" type="button" class="btn btn-primary"><i class="icon-facebook"></i>   Sign Up with Facebook</button>
                                    </div>                                           
                                        
                                </div>
                                
                                
                                
                            </form>
                         </div>
                    </div>

               
               
                
         </div> 
    </div>
    
    </form>
</body>
</html>
